$(function (){
    let permission;
    let user1;

    function setUserInfo(){
        let ratio = user1.score/96296;
        if(ratio<1&&user1.score!=0){
            ratio=1;
        }
        if(permission>0){
            $(".userHeader").attr("src","/userHeader/"+user1.header_url)
            $(".userAlias").text(user1.alias)
            $(".progress-bar").removeAttr("style")
            $(".progress-bar").attr("style","width:"+ratio+"%")
            $(".progress-bar").attr("aria-valuenow",ratio)
            $(".userScore").text(user1.score)
            $(".userGroup").text(user1.group_alias)
            $(".userState-all-isLogin").removeAttr("hidden")
            $(".userState-all-notLogin").attr("hidden","true")
            if(permission>=150){

                $(".userState-admin").removeAttr("hidden")
            }else{
                // $(".userState-all-isLogin").removeAttr("hidden")
                // $(".userState-all-notLogin").attr("hidden","true")
                $(".userState-admin").attr("hidden","true")
            }
        }else{
            $(".userState-all-notLogin").removeAttr("hidden")
            $(".userState-all-isLogin").attr("hidden","true")
            $(".userState-admin").attr("hidden","true")
        }
    }
    function getData(){
        $.ajax({
            url: "/user/getUserPermission", // 请求路径
            type: "POST", //请求方式
            success: function (dataJ) {
                // alert("尝试获取用户权限成功！权限:"+dataJ+"!");
                permission = dataJ
            }, //响应成功后的回调函数
            error: function (data) {
                alert("尝试获取用户权限信息失败！");
            }
        })
        $.ajax({
            url: "/user/getIsLoginUser", // 请求路径
            type: "POST", //请求方式
            success: function (dataJ) {
                // alert("尝试获取用户信息成功！欢迎你，"+dataJ.alias+"!");
                user1 = dataJ
                setUserInfo(dataJ)
            }, //响应成功后的回调函数
            error: function (data) {
                alert("尝试获取用户信息失败！");
            }
        })
    }
    window.onloadstart(getData(),setTimeout(setUserInfo, 100))

});
